<%-- 
    Document   : createLab
    Created on : Jun 29, 2011, 1:19:08 PM
    Author     : Tyler Powell
--%>
<jsp:useBean id="courseData" scope="application" class="edu.gatech.gellinservlet.model.CourseManager" />
<jsp:useBean id="labData" scope="application" class="edu.gatech.gellinservlet.model.LabManager" />
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Lab Creation - Lab Assistant Pro</title>
    </head>
    <body>
        <%@include file="pro_header.jsp" %>     
        <% //if the user is an admin, load the admin link bar
        User pageTempVar = (User)session.getAttribute("persistUser");
        if(pageTempVar instanceof SystemAdmin)
          {
        %>
        <%@include file="admin_list.jsp" %>
        <% } //ends user_redirect else statement, html is included here %>
        <% } //ends verifySession.jsp, all html is included in else statment %>
        <% } //if the user is an instructor, load the instructor link bar
        else if(pageTempVar instanceof Instructor)
          {
        %>
        <%@include file="instr_list.jsp" %>
        <% } //ends user_redirect else statement, html is included here %>
        <% } //ends verifySession.jsp, all html is included in else statment %>
        <%} //if the user is a student, send him home
        else
       {
                response.sendRedirect("stude_home.jsp");
       }%>
       
        <center><h1>Create a New Lab!</h1></center>
    <table ALIGN="center" border="1" cellspacing="0" cellpadding="0">
        <form action="makeLab.jsp" method="post">
            <thead>
                <tr>
                    <th></th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Lab Name:</td>
                    <td><input type="text" name="name" value=""/></td>
                </tr>
                <tr>
                    <td>For Course:</td>
                    <td><select name="course">
                            <% //create the drop down list containing courses
                            //if an admin is making a lab, give him all the courses
                            String name = "";
                            if(pageTempVar instanceof SystemAdmin)
                            {
                                    for(Course aCourse : courseData.getDataList())
                                    {
                                        name = aCourse.getName();
                                        out.println("<option value=\"" + name + "\">");
                                        out.println(name);
                                        out.println("</option>");
                                    }
                            }
                            //if an instructor is making a lab, give him only his courses
                            else if(pageTempVar instanceof Instructor)
                            {
                                   for(Course aCourse : ((Instructor)pageTempVar).getCourseList())
                                   {
                                        name = aCourse.getName();
                                        out.println("<option value=\"" + name + "\">");
                                        out.println(name);
                                        out.println("</option>");
                                   }
                                   
                            }
                            %>
                                
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Team Selection:</td>
                    <td>
                        <input type="radio" name="teamType" value="none"> No Teams<br>
                        <input type="radio" name="teamType" value="random"> Random<br>
                        <input type="radio" name="teamType" value="self" checked> Student Assignment
                    </td>
                </tr>
                <tr>
                    <td>Max Team Size:</td>
                    <td><input type="text" name="size" value=""/><br>
                        Default = 5</td>
                </tr>
                <tr>
                    <td>Start Date:</td>
                    <td><input type="text" name="startDate" value=""/></td>
                </tr>
                <tr>
                    <td>Start Time:</td>
                    <td><input type="text" name="startTime" value=""/></td>
                </tr>
                <tr>
                    <td>End Date:</td>
                    <td><input type="text" name="endDate" value=""/></td>
                </tr>
                <tr>
                    <td>Start Time:</td>
                    <td><input type="text" name="endTime" value=""/></td>
                </tr>
                <tr>
                    <td><input type="submit" value="Create Lab" name="createLab"/>
                        </input></td>
                </tr>
                
            </tbody>

        </form>
    </table>
            <center>
            <% //if a lab is valid, print out lab created
            String code = request.getParameter("code");
            if ("valid".equals(code))
            {
                out.println("<font color=red>Lab Created!</font>");
            }
            else if("invalid".equals(code))
            {
                out.println("<font color=red>Enter a valid team size, integers only!</font>");
            }
            %>
            </center>
    </body>
</html>
